﻿
/**
	随机数字
*/
	function randomInt(min,max){
			return Math.round(Math.random()*(max-min)+min);
			
		}
		
	
/**
	随机颜色
*/	
		
		function randomColor(){
			var R = randomInt(0,255).toString(16);
			var G = randomInt(0,255).toString(16);
			var B = randomInt(0,255).toString(16);
			
			return "#"+(R.length<2?"0"+R:R) + (G.length<2?"0"+G:G) + (B.length<2?"0"+B:B);
		}
/**
	只要元素节点
*/
	function getElementNode(node){
		var list = [];
		for(var i=0;i<node.length;i++){
			if(node[i].nodeType == 1){
				list.push(node[i]);
			}
		}
		return list;
	}

/**
	加载条的兼容(IE 和其它)		
*/
	function onldcompatible(part){
				if(part.currentStyle){
					return part.currentStyle.width;
				}else {
					return  window.getComputedStyle(part,null).width;
				}
			}
/**
设置Cookie
*/
function setCookie(Name,val,num){
		var _date = new Date()
		_date.setDate( _date.getDate()+num ); 
		document.cookie = Name + "=" + val  + "; expires =" + _date;
}
/**
根据cookie中的属性获取相应的属性值
*/
function getCookie(ele){
		var _cookie = document.cookie.split("; ");
		for(var i = 0;i<_cookie.length;i++){
			var list = _cookie[i].split("=");
			if(list[0] == ele){
				return list[1];				
			}
		}return "";
}
/**获取父元素距离边界的位置
*/
	function getLocation(ele){//获取box到边界的距离
		var totalX = 0;
		var totalY = 0;
		totalX += ele.offsetLeft;
		totalY += ele.offsetTop;
		while(ele.offsetParent){
			ele = ele.offsetParent;
			totalX += ele.offsetLeft;
			totalY += ele.offsetTop;
		}
		var location = {
			x : totalX,
			y : totalY
		}
		return location;
	}
	/**将字符串转换为date
	*/
	function string2date(str,sep){
			str = str.replace(sep, "-");
			return new Date(str);
		}
	/**将date转换为字符串
	*/			
		function date2string(d, sep){
			 sep = sep || "/";
			 return d.getFullYear()+sep+(d.getMonth()+1)+sep+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
		}
	/**定点抛物线
	 */
	function parabola(objStart,objEnd){
				var a = 0.001;
				var endPosition = {
					x:getLocation(objEnd).x-getLocation(objStart).x,
					y:getLocation(objEnd).y-getLocation(objStart).y
				};
				var b = ( endPosition.y - a*endPosition.x*endPosition.x )/endPosition.x;
				var startx = getLocation(objStart).x;
				var starty = getLocation(objStart).y;
				var x=0;
				var t = setInterval(function(){
					x +=  10;
					var y = a*x*x + b*x;
					objStart.style.left = x + startx + "px";
					objStart.style.top = y + starty + "px";
					if(getLocation(objStart).x>=getLocation(objEnd).x){
						clearInterval(t);
						objStart.style.display = "none";
					}
				},20)
			}
	
	
	
	
	
	